package com.wcg.test.service;

import com.wcg.test.mapper.UserMapper;
import com.wcg.test.pojo.User;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Slf4j
public class UserService {

    @Autowired
    private UserMapper userMapper;


    /**
     * 查询所有用户信息
     * @return List<User>
     */
    public List<User> qryUserList(){

        return null;
    }


    /**
     * 用户登录校验
     * @param account
     * @param password
     * @return
     */
    public String login(String account,String password){
        String login = userMapper.login(account, password);
        if(login == null){
            log.info("账号密码错误！请重新输入。");
            return null;
        }
        return login;
    }


    public int register(User user){
        int register = userMapper.register(user);
        if(register <= 0){
            log.info("注册失败！！");
            return 0;
        }
        return 1;
    }
}
